package ICTCLAS.I3S.AC;
import java.io.*;

public class ICTCLAS50
{
	//public enum eCodeType
	//{
	//    CODE_TYPE_UNKNOWN,//type unknown 
	//    CODE_TYPE_ASCII,//ASCII
	//    CODE_TYPE_GB,//GB2312,GBK,GB10380
	//    CODE_TYPE_UTF8,//UTF-8
	//    CODE_TYPE_BIG5//BIG5
	//}
	
	public native boolean ICTCLAS_Init(byte[] sPath);
	public native boolean ICTCLAS_Exit();
	public native int ICTCLAS_ImportUserDictFile(byte[] sPath,int eCodeType);
	public native int ICTCLAS_SaveTheUsrDic();
	public native int ICTCLAS_SetPOSmap(int nPOSmap);
	public native boolean ICTCLAS_FileProcess(byte[] sSrcFilename, int eCodeType, int bPOSTagged,byte[] sDestFilename);
	public native byte[] ICTCLAS_ParagraphProcess(byte[] sSrc, int eCodeType, int bPOSTagged);
	public native byte[] nativeProcAPara(byte[] sSrc, int eCodeType, int bPOStagged);
	/* Use static intializer */
	static
	{
		System.loadLibrary("ICTCLAS50");
	}
	  private static ICTCLAS50 instance=null;
	  private ICTCLAS50() {
			String argu = ".";
		  try {
				if (ICTCLAS_Init(argu.getBytes("GB2312")) == false) {
					System.out.println("Init Fail!");
					return;
				} else {
					System.out.println("Init Succeed!");
				}
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	  }

	  public synchronized static ICTCLAS50 getInstance(){
	    if (instance==null){
	      instance = new ICTCLAS50();
	    }
	    return instance;
	  }
	public String paragraphProcess(String sSentence) throws UnsupportedEncodingException {

		byte nativeBytes[] = getInstance().ICTCLAS_ParagraphProcess(
				sSentence.getBytes("GB2312"), 0, 1);
		System.out.println(nativeBytes.length);
		String nativeStr = new String(nativeBytes, 0, nativeBytes.length,
				"GB2312");
		return nativeStr;
	}
}


